/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pima.gestrest.model;


import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.Transient;


@Entity
@NamedQuery(name = Ville.FIND_ALL, query = "SELECT b FROM Ville b")

public class Ville implements Serializable {
   public final static String FIND_ALL = "Ville.findAll";
   public final static String Del_SOM = "Ville.delete";

 @Id
    @GeneratedValue
    private Long id;
    @Column(nullable = false)
    private String title;
    @Column(length = 2000)
    private String description;
    private String cp;
    @Transient
    private Boolean selected;

    // ======================================
    // =            Constructors            =
    // ======================================

    public Ville() {
    }

    public Ville(String title, String description, String cp) {
        this.title = title;
        this.description = description;
        this.cp = cp;
    }

    // ======================================
    // =          Getters & Setters         =
    // ======================================
    public Long getId() {
        return id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getCp() {
        return cp;
    }

    public void setCp(String cp) {
        this.cp = cp;
    }

    public Boolean isSelected() {
        return selected;
    }

    public Boolean getSelected() {
        return selected;
    }

    public void setSelected(Boolean selected) {
        this.selected = selected;
    }

    // ======================================
    // =         hash, equals, toString     =
    // ======================================

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("Ville");
        sb.append("{id=").append(id);
        sb.append(", title='").append(title).append('\'');
        sb.append(", description='").append(description).append('\'');
        sb.append(", cp='").append(cp).append('\'');
        sb.append('}');
        return sb.toString();
    }


    @Override
    public boolean equals(Object obj) {
       if(((Ville)obj).getTitle().equals(title) && ((Ville)obj).getCp().equals(cp) && ((Ville)obj).getId().equals(id))
            return true;
        else
            return false;
    }
}

